import "package:ct_pa_majordomo/config/theme_vars.dart";
import "package:ct_pa_majordomo/pages/widgets/textarea_form_field.dart";
import "package:ct_pa_majordomo/widgets/button/index.dart";
import "package:ct_pa_majordomo/widgets/normal_scaffold/index.dart";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";

class EditRemark extends StatefulWidget {
  final String remark;
  const EditRemark({super.key, required this.remark});

  @override
  State<StatefulWidget> createState() => _EditRemarkState();

}

class _EditRemarkState extends State<EditRemark> {

  String _remark = "";

  @override
  void initState() {
    setState(() {
      _remark = widget.remark;
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return NormalScaffold(
      title: "编辑备注",
      child: ListView(
        padding: const EdgeInsets.all(ThemeVars.paddingPage),
        children: [
          TextAreaFormField(
            initialValue: _remark,
            maxLength: 150,
            onChanged: (value) => setState(() {
              _remark = value;
            }),
          ),
          const SizedBox(height: 30,),
          Button(
            onPressed: _remark.isNotEmpty ? () {
              Navigator.pop(context, _remark);
            } : null,
            child: Text("保存")
          )
        ],
      ),
    );
  }

}